<template>
  <el-container>
    <el-main class="mainDetails">
      <!-- 页面主体内容 -->
      <TCollapse
        v-for="item in collapseList"
        :key="item.components"
        v-model="activeNames"
        :title="item.title"
      >
        <component
          :is="item.components"
          :ref="item.components"
          :project-info="projectInfo"
          :file-data="tableData"
          @search="handleSearch"
        />
      </TCollapse>
    </el-main>
  </el-container>
</template>

<script>
import PrjBaseDetail from './components/prjBaseDetail'
import logisticsBack from './components/logisticsBack'
import materialDetail from './components/materialDetail.vue'
import yardView from './components/yardView'
import HeaderTitle from '@/components/basic/HeaderTitle'
import PrjAcceptInfo from '@/views/acceptanceManagement/servicecodeDetailConfig/PrjAcceptInfo'
import PrjSiteDetail from './components/PrjSiteDetail'
import materialsApplication from './components/materialsApplication.vue'
import TCollapse from '@/components/basic/TCollapse.vue'
// import * as Common from '@/api/common'
import {
    queryReceiveReturnOverview,
    queryReceiveDetails
} from '@/api/material'
export default {
    name: 'AcceptMangeDetail',
    components: {
        materialsApplication,
        PrjBaseDetail,
        yardView,
        logisticsBack,
        PrjAcceptInfo,
        HeaderTitle,
        PrjSiteDetail,
        materialDetail,
        TCollapse
    },
    data() {
        return {
            headerTitle: '物资管理详情',
            activeNames: [],
            collapseList: [
                { title: '查询条件', components: 'PrjSiteDetail' },
                { title: '物资领用退库总览', components: 'logisticsBack' },
                { title: '一码到底物资总览', components: 'yardView' }
            ],
            childData: {},
            buttonDisable: ['doNext'],
            selectList: {},
            projectInfo: {},
            logisticsName: [],
            tableData: []
        }
    },
    computed: {
        query() {
            return this.$route.query
        },
        queryWorkItemId() {
            return this.$route.query.WorkItemId
        }
    },
    async created() {
        const res = await queryReceiveDetails({ prjId: this.query.prjId })
        if (+res.code === 200) {
            this.projectInfo = res.data.prjInfo
        }
        this.queryReceiveReturnOverview({ prjId: this.query.prjId })
    },
    mounted() {
        this.collapseList.map((item) => {
            this.childData[item.components] =
                this.$refs[item.components][0].$data
        })
        this.activeNames = this.collapseList.map((item) => item.components)
    },
    methods: {
        handleNext() {
            console.log(1111)
        },
        async queryReceiveReturnOverview(form) {
            const resRetreat = await queryReceiveReturnOverview({ ...form })
            if (+resRetreat.code === 200) {
                this.tableData = resRetreat.data
            }
        },
        handleSearch(form) {
            this.queryReceiveReturnOverview({
                prjId: this.query.prjId,
                ...form
            })
            this.$refs.yardView[0].queryLableCodeList({
                prjId: this.query.prjId,
                ...form
            })
        }
    }
}
</script>

<style scoped>
.mainDetails {
    padding: 15px 25px;
}

.el-collapse-item__header {
    padding-left: 20px;
    font-size: 14px;
    color: #333333;
    letter-spacing: 0;
    font-weight: 600;
}

.item_icon {
    width: 6px;
    background: rgb(235, 75, 75);
    height: 15px;
    margin-right: 10px;
    border-radius: 10px;
}

.content-box {
    width: 100%;
    border-radius: 3px;
    font-size: 12px;
    font-weight: 400;
    line-height: 25px;
}
</style>
